package com.hnust.controller;

import com.hnust.service.GetReviewInfoService;
import com.hnust.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin("*")
@RestController

@RequestMapping("/check")
public class ReviewInfoController {
    @Autowired
    private GetReviewInfoService getReviewInfoService;

    @GetMapping("/getInformation")
    public Result<Map<String,List<Integer>>> getReviewInfo(
            @RequestParam(value = "testId") String testId,
            @RequestParam(value = "studentId") String studentId) {
        List<Integer> reviewInfo = getReviewInfoService.getReviewInfo(testId,studentId);
        Map<String,List<Integer>> review = new HashMap<>();
        review.put("score",reviewInfo);
        if(reviewInfo==null){
            return new Result<>(0, "获取失败", null);
        }
        else{
            return new Result<>(1, "获取成功", review);
        }
    }
}
